import postApi from '../../utils/http/api'
import postApiNew from '../../utils/http/api-new'

export default {
  //获取专题详情
  getSubject(subjectId) {
    return postApiNew({
      actionCode: 'zhiye-media',
      path: '/level/subject/getOrgLevelSubjectDetailById',
      requestData: {
        'id': subjectId,
      }
    })
  },
  //获取专题 subjectId:主题id,typeId=1:视频 2:音频  3:文档 4:测试
  getSubjectContain(id, type) {
    return postApiNew({
      actionCode: 'zhiye-media',
      path: '/level/subject/getSubjectContain',
      requestData: {
        subjectId: id,
        type: type
      },
    })
  },
  //获取是否完成学习任务
  getExamLimitBySubjectId(id) {
    return postApi({
      actionCode: '100531',
      method: 'getExamLimitBySubjectId',
      requestData: {
        subjectId: id,
      },
    })
  },

  //播放记录（视频、电台）type 1 视频，2 电台
  // requestData:'{"courseId":' + $p_courseId + ',"type":"1","id":"' + vmVideoDetail.media.id + '","subjectId":' + $p_subId + '}'
  playRecord(record) {
    return postApi({
      actionCode: '300100',
      method: 'playRecord',
      requestData: {
        courseId: record.courseId,
        type: record.type,
        id: record.id,
        subjectId: record.subjectId,
      },
    })
  },

  //4.3获取有效期内的报名专题列表
  getMyValidSubjectList() {
    return postApi({
      actionCode: '100520',
      method: 'getMyValidSubjectList',
      requestData: {
        "hasOverallExam": 1,
      }
    })
  },
  // 4.4获取过期的报名专题列表
  getMyInvalidSubjectList() {
    return postApi({
      actionCode: '100520',
      method: 'getMyInvalidSubjectList',
      requestData: {
        "hasOverallExam": 1,
      }
    })
  },

  //获取视频详情
  //requestData:'{"courseId":' + $p_courseId + ',"sourceType":"' + $p_sourceType + '"' + ($p_sourceType == 4 ? ',"catId":"' + $p_catId + '"' : "") + ',"mediaId":"' + ($p_mediaId != "" ? $p_mediaId : '') + '"}'
  getCourseInfo(courseId, sourceType, catId, mediaId) {
    return postApi({
      actionCode: '300100',
      method: 'getCourseInfo',
      requestData: {
        courseId: courseId,
        sourceType: sourceType,
        catId: catId,
        mediaId: mediaId
      },
    })
  },

  //获取M3U8播放地址p
  //type 1 视频，2 电台
  //"courseType":1,"mediaId":43,"subjectId":150,"courseId":40,"ip":"192.168.2.1"
  playMedia(playData) {
    return postApiNew({
      actionCode: 'zhiye-media',
      path: '/level/media/playMedia',
      requestData: {
        courseType: playData.courseType,
        mediaId: playData.mediaId,
        subjectId: playData.subjectId,
        courseId: playData.courseId,
        isSp: 0,
        ip: returnCitySN.cip,
      },
    })
  },
  //KZL 4.4获取专题下的考试列表
  getExamsBySubjectId(subjectId) {
    return postApiNew({
      actionCode: 'zhiye-media',
      path: '/overall/exam/getExamsBySubjectId',
      requestData: {
        subjectId
      }
    })
  },

}
